package com.dolphin.common.component.var.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author shida
 */

@Getter
public enum PeriodTypeEnum {
    UNSET(Integer.valueOf(0), "未设置"),
    WINDOW(Integer.valueOf(1), "时间周期"),
    FREQUENCY(Integer.valueOf(2), "时间周期范围"),
    NATURE_ACTION(Integer.valueOf(3), "自然周期"),
    LIST(Integer.valueOf(4), "当前数据LIST")
    ;

    private Integer id;
    private String description;

    PeriodTypeEnum(Integer id, String description) {
        this.id = id;
        this.description = description;
    }

    public static PeriodTypeEnum formString(String periodType){
        if(StringUtils.isEmpty(periodType)){
            return null;
        }

        for(PeriodTypeEnum item : values()){
            if(item.name().equals(periodType)){
                return item;
            }
        }

        throw new RuntimeException("Unsupported PeriodTypeEnum:" + periodType);
    }
}
